//
//  DictionaryHelper.swift
//  CommonTools
//
//  Created by xianquan on 2023/12/2.
//

import Foundation


public extension Dictionary {
    mutating func merge(dict: [Key: Value]){
        for (k, v) in dict {
            updateValue(v, forKey: k)
        }
    }
    
    func toJsonString() -> String? {
        if let jsonData = try? JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) {
            let jsonString = String(data: jsonData, encoding: String.Encoding.utf8)
            return jsonString
        }
        return nil
    }
}
